clear;clc;
y0 = [0 1];
h = 0.1;
tspan = [0 10];
N = 1/h +1 ;
alphat = [0.01 0.99];
ah = 0.01;
MM = (alphat(2) -alphat(1))/ah ;
T = [];
global a
for a=alphat(1):ah:alphat(2)
    varphi = sqrt(3)/pi*log(a/(1-a));
    [y,~] = RepMilneHammin(@example2,tspan,y0,h);
    [yy,~] = MilneHammin(@example2,tspan,y0,h);
    [yyy,~] = RungeKutta4(@example2,tspan,y0,h);
    [yyyy,t] = AdamsSimpson(@example2,tspan,y0,h);
    
    M = length(t);
    z = (exp(t+varphi*t)-1)/(1+varphi);
    
    T = [T;y(N,1),yy(N,1),yyy(N,1),yyyy(N,1),z(N,1)];
    
%     e = sum((y(:,1)-z).^2)/M;
%     ee = sum((yy(:,1)-z).^2)/M;
%     eee = sum((yyy(:,1)-z).^2)/M;
%     eeee = sum((yyyy(:,1)-z).^2)/M;
%     [e,ee,eee,eeee]
%     
%     figure
%     plot(t,y(:,1),t,yy(:,1),t,yyy(:,1),t,yyyy(:,1),t,z);

end
alpha = alphat(1):ah:alphat(2);
alpha = alpha';

plot(T(:,1),alpha,'-o',T(:,2),alpha,'-.',T(:,3),alpha,'-*',T(:,4),alpha,'-x',T(:,5),alpha);
legend('RepMilneHammin','MilneHammin','RungeKutta4','AdamsSimpson','Exact solution')
xlabel('x_{t}^{\alpha}','FontName','times new Roman','FontSize',15)
ylabel('\alpha','FontName','times new Roman','FontSize',15); 


MSE = [sum((T(:,1)-T(:,5)).^2)/MM,sum((T(:,2)-T(:,5)).^2)/MM,sum((T(:,3)-T(:,5)).^2)/MM,sum((T(:,4)-T(:,5)).^2)/MM];
MAE = [sum(abs(T(:,1)-T(:,5)))/MM,sum(abs(T(:,2)-T(:,5)))/MM,sum(abs(T(:,3)-T(:,5)))/MM,sum(abs(T(:,4)-T(:,5)))/MM];

MSE
MAE